package com.uenpay.im.ui.old.activity.chat.manage;

import com.qyx.android.message.type.MsgContentType;
import com.qyx.android.protocol.QyxMsg;
import com.uenpay.im.IMApplication;
import com.uenpay.im.ui.old.activity.chat.MsgOtherType;

/**
 * @author SL
 * @created 2016-4-23 下午1:01:55
 * @copyRight http://www.qiyunxin.com
 * @function 会话类型
 */
public class ChatTypeManage {

    /**
     * 系统消息
     */
    public final static int TALK_SYSTEM = 0;
    /**
     * 接收文本
     */
    public final static int TALK_RECEIVED_TEXT = 1;
    /**
     * 接收图片
     */
    public final static int TALK_RECEIVED_IMAGE = 2;
    /**
     * 接收语音
     */
    public final static int TALK_RECEIVED_AUDIO = 3;
    /**
     * 接收地理位置
     */
    public final static int TALK_RECEIVED_LOCATION = 4;
    /**
     * 接收Gif
     */
    public final static int TALK_RECEIVED_GIF = 5;
    /**
     * 接收文件
     */
    public final static int TALK_RECEIVED_FILE = 12;

    /**
     * 发送文本
     */
    public final static int TALK_SEND_TEXT = 6;
    /**
     * 发送图片
     */
    public final static int TALK_SEND_IMAGE = 7;
    /**
     * 发送语音
     */
    public final static int TALK_SEND_AUDIO = 8;
    /**
     * 发送地理位置
     */
    public final static int TALK_SEND_LOCATION = 9;
    /**
     * 发送Gif
     */
    public final static int TALK_SEND_GIF = 10;
    /**
     * 发送文件
     */
    public final static int TALK_SEND_FILE = 13;
    /**
     * 系统时间
     */
    public final static int TALK_TIME = 11;
    /**
     * 未读消息提醒线
     */
    public final static int TALK_UNREAD_MSG = 14;
    /**
     * 收到名片
     */
    public final static int TALK_RECEIVED_CRAD = 15;
    /**
     * 发送名片
     */
    public final static int TALK_SEND_CRAD = 16;
    /**
     * 收到的红包
     */
    public final static int TALK_RECEIVED_RED = 17;
    /**
     * 发送的红包
     */
    public final static int TALK_SEND_RED = 18;
    /**
     * 红包系统消息
     */
    public final static int TALK_RED_SYSTEM = 19;
    /**
     * 收到的视频聊天
     */
    public final static int TALK_RECEIVED_VIDEO_CHAT = 20;
    /**
     * 发送的视频聊天
     */
    public final static int TALK_SEND_VIDEO_CHAT = 21;

    /**
     * 接受OA类型消息
     */
    public final static int TALK_RECEIVED_OA = 22;
    /**
     * 发送OA类型消息
     */
    public final static int TALK_SEND_OA = 23;
    /**
     * 接受OA类型通知
     */
    public final static int TALK_RECEIVED_OA_NOTICE = 24;
    /**
     * 发送OA类型通知
     */
    public final static int TALK_SEND_OA_NOTICE = 25;
    /**
     * 接受OA类型任务
     */
    public final static int TALK_RECEIVED_TASK = 26;
    /**
     * 发送OA类型任务
     */
    public final static int TALK_SEND_TASK = 27;
    /**
     * 接受新闻
     */
    public final static int TALK_RECEIVED_NEWS = 28;
    /**
     * 好友验证消息
     */
    public final static int TALK_VERIF_MSG = 29;
    /**
     * 收到的转账
     */
    public final static int TALK_RECEIVED_TRANSFER = 30;
    /**
     * 发送的转账
     */
    public final static int TALK_SEND_TRANSFER = 31;
    /**
     * 接受的众筹(江湖救急)
     */
    public final static int TALK_RECEIVED_CROWNFUND = 32;
    /**
     * 发送的众筹(江湖救急)
     */
    public final static int TALK_SEND_CROWNFUND = 33;
    /**
     * 众筹系统消息
     */
    public final static int TALK_CROWD_FUND_SYSTEM_INFO = 34;
    /**
     * 接收邀请加入群聊
     */
    public final static int TALK_RECEIVED_INVIT_JOIN_GROUP = 35;
    /**
     * 发送邀请加入群聊
     */
    public final static int TALK_SEND_INVIT_JOIN_GROUP = 36;
    /**
     * 发送收经费消息
     */
    public final static int TALK_SEND_RECEIVE_FUNDS = 37;
    /**
     * 经费系统消息
     */
    public final static int TALK_FUNDS_SYSTEM_INFO = 38;
    /**
     * 接收到收经费消息类型
     */
    public final static int TALK_RECEIVED_RECEIVE_FUNDS = 39;

    /**
     * 接受的视频
     */
    public final static int TALK_RECEIVED_VIDEO = 40;
    /**
     * 发送的视频
     */
    public final static int TALK_SEND_VIDEO = 41;

    /**
     * 消息类型对应View
     *
     * @param message
     * @return
     */
    public static int getItemViewType(QyxMsg message) {
        int type = TALK_SYSTEM;
        if (message == null)
            return type;
        if (message.msg_content_type != 0) {
            type = message.msg_content_type;
        }

        if (type == MsgOtherType.msgTime) {
            return TALK_TIME;
        } else if (type == MsgOtherType.msgPromptNewMsg) {
            return TALK_UNREAD_MSG;
        } else if (type == MsgOtherType.msgVerifMsg) {
            return TALK_VERIF_MSG;
        }

        if ((message.from_cust_id + "").equals(IMApplication.getCustId())) {
            switch (type) {
                case MsgContentType.TEXT:
                    return TALK_SEND_TEXT;
                case MsgContentType.ALTER_GROUP_TALK_INTRO:
                    return TALK_SEND_TEXT;
                case MsgContentType.ACCESS_FRIEND_VERIFY:
                    return TALK_SEND_TEXT;
                case MsgContentType.PIC:
                    return TALK_SEND_IMAGE;
                case MsgContentType.GIF_EXP:
                    return TALK_SEND_GIF;
                case MsgContentType.AUDIO:
                    return TALK_SEND_AUDIO;
                case MsgContentType.LOCATION:
                    return TALK_SEND_LOCATION;
                case MsgContentType.FILE:
                    return TALK_SEND_FILE;
                case MsgContentType.BUSINESS_CRAD:
                    return TALK_SEND_CRAD;
                case MsgContentType.RED:
                    return TALK_SEND_RED;
                case MsgContentType.RECEIVED_RED_SYSTEM_MSG:
                    return TALK_RED_SYSTEM;
                case MsgContentType.REQUEST_VIDEO_CHAT:
                    return TALK_SEND_VIDEO_CHAT;
                case MsgContentType.OA_APPROVAL:
                    return TALK_SEND_OA;
                case MsgContentType.OA_REIMBURSEMENT:
                    return TALK_SEND_OA;
                case MsgContentType.OA_NOTICE:
                    return TALK_SEND_OA_NOTICE;
                case MsgContentType.OA_TASK:
                    return TALK_SEND_TASK;
                case MsgContentType.PUBLIC_NUM_NEWS:
                    return TALK_RECEIVED_NEWS;
                case MsgContentType.TRANSFER_ACCOUNTS:
                    return TALK_SEND_TRANSFER;
                case MsgContentType.CROWD_FUND:
                    return TALK_SEND_CROWNFUND;
                case MsgContentType.CROWD_FUND_SYSTEM_MSG:
                    return TALK_CROWD_FUND_SYSTEM_INFO;
                case MsgContentType.ACCEPT_JOIN_ORG:
                    return TALK_SEND_INVIT_JOIN_GROUP;
                case 10002:
                    return TALK_SEND_RECEIVE_FUNDS;
                case 10001:
                    return TALK_FUNDS_SYSTEM_INFO;
                case 10003:
                    return TALK_FUNDS_SYSTEM_INFO;
                case MsgContentType.VIDEO:
                    return TALK_SEND_VIDEO;
                default:
                    break;
            }
        } else {
            switch (type) {
                case MsgContentType.TEXT:
                    return TALK_RECEIVED_TEXT;
                case MsgContentType.ALTER_GROUP_TALK_INTRO:
                    return TALK_RECEIVED_TEXT;
                case MsgContentType.ACCESS_FRIEND_VERIFY:
                    return TALK_RECEIVED_TEXT;
                case MsgContentType.PIC:
                    return TALK_RECEIVED_IMAGE;
                case MsgContentType.GIF_EXP:
                    return TALK_RECEIVED_GIF;
                case MsgContentType.AUDIO:
                    return TALK_RECEIVED_AUDIO;
                case MsgContentType.LOCATION:
                    return TALK_RECEIVED_LOCATION;
                case MsgContentType.FILE:
                    return TALK_RECEIVED_FILE;
                case MsgContentType.BUSINESS_CRAD:
                    return TALK_RECEIVED_CRAD;
                case MsgContentType.RED:
                    return TALK_RECEIVED_RED;
                case MsgContentType.RECEIVED_RED_SYSTEM_MSG:
                    return TALK_RED_SYSTEM;
                case MsgContentType.REQUEST_VIDEO_CHAT:
                    return TALK_RECEIVED_VIDEO_CHAT;
                case MsgContentType.OA_APPROVAL:
                    return TALK_RECEIVED_OA;
                case MsgContentType.OA_REIMBURSEMENT:
                    return TALK_RECEIVED_OA;
                case MsgContentType.OA_NOTICE:
                    return TALK_RECEIVED_OA_NOTICE;
                case MsgContentType.OA_TASK:
                    return TALK_RECEIVED_TASK;
                case MsgContentType.PUBLIC_NUM_NEWS:
                    return TALK_RECEIVED_NEWS;
                case MsgContentType.TRANSFER_ACCOUNTS:
                    return TALK_RECEIVED_TRANSFER;
                case MsgContentType.CROWD_FUND:
                    return TALK_RECEIVED_CROWNFUND;
                case MsgContentType.CROWD_FUND_SYSTEM_MSG:
                    return TALK_CROWD_FUND_SYSTEM_INFO;
                case MsgContentType.ACCEPT_JOIN_ORG:
                    return TALK_RECEIVED_INVIT_JOIN_GROUP;
                case 10002:
                    return TALK_RECEIVED_RECEIVE_FUNDS;
                case 10001:
                    return TALK_FUNDS_SYSTEM_INFO;
                case 10003:
                    return TALK_FUNDS_SYSTEM_INFO;
                case MsgContentType.VIDEO:
                    return TALK_RECEIVED_VIDEO;
            }
        }

        return TALK_SYSTEM;
    }
}
